package com.tencent.ied.bk.filter.impl;

import com.tencent.ied.bk.constant.CommonConstant;
import com.tencent.ied.bk.entity.BaseAbstractInfo;
import com.tencent.ied.bk.filter.AbstractFilter;

/**
 * @author chen_yu
 * @date 2021/3/11 3:09
 */
public class WordNumFilter extends AbstractFilter {

    public WordNumFilter(String name) {
        super(name);
    }

    @Override
    public boolean doFilter(BaseAbstractInfo baseAbstractInfo) {
        String[] words = baseAbstractInfo.getContent().toLowerCase().split("[^(a-zA-Z)]+");
        if (words.length > CommonConstant.ABSTRACT_WORD_NUM_LIMIT) {
            return false;
        }
        baseAbstractInfo.setWords(words);
        return true;
    }
}
